/*
 * (c) Copyright Microsoft Corporation. 
 * This source is subject to the Microsoft Public License.
 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL       
 */
package com.microsoft.hsg;

import com.microsoft.hsg.util.EnumCode;
import com.microsoft.hsg.util.EnumCodeLookup;

/**
 * The Enum StatusCode with all the known error codes from 
 * HealthVault.
 */
public enum StatusCode implements EnumCode {
	
	/** The OK. */
	OK(0),
	
	/** The FAILED. */
	FAILED(1),
	
	/** The BA d_ http. */
	BAD_HTTP(2),
	
	/** The INVALI d_ xml. */
	INVALID_XML(3),
	
	/** The BA d_ sig. */
	BAD_SIG(4),
	
	/** The BA d_ method. */
	BAD_METHOD(5),
	
	/** The INVALI d_ app. */
	INVALID_APP(6),
	
	/** The CREDENTIA l_ toke n_ expired. */
	CREDENTIAL_TOKEN_EXPIRED(7),
	
	/** The INVALI d_ token. */
	INVALID_TOKEN(8),
	
	/** The INVALI d_ person. */
	INVALID_PERSON(9),
	
	/** The INVALI d_ record. */
	INVALID_RECORD(10),
	
	/** The ACCES s_ denied. */
	ACCESS_DENIED(11),
	
	/** The NYI. */
	NYI(12),
	
	/** The INVALI d_ thing. */
	INVALID_THING(13),
	
	/** The CAN t_ conver t_ units. */
	CANT_CONVERT_UNITS(14),
	
	/** The INVALI d_ filter. */
	INVALID_FILTER(15),
	
	/** The INVALI d_ format. */
	INVALID_FORMAT(16),
	
	/** The MISSIN g_ share d_ secret. */
	MISSING_SHARED_SECRET(17),
	
	/** The INVALI d_ appauth. */
	INVALID_APPAUTH(18),
	
	/** The INVALI d_ thin g_ type. */
	INVALID_THING_TYPE(19),
	
	/** The THIN g_ typ e_ immutable. */
	THING_TYPE_IMMUTABLE(20),
	
	/** The THIN g_ typ e_ uncreatable. */
	THING_TYPE_UNCREATABLE(21),
	
	/** The DUPLICAT e_ credentia l_ found. */
	DUPLICATE_CREDENTIAL_FOUND(22),
	
	/** The INVALI d_ recor d_ name. */
	INVALID_RECORD_NAME(23),
	
	/** The DRU g_ no t_ found. */
	DRUG_NOT_FOUND(24),
	
	/** The INVALI d_ perso n_ state. */
	INVALID_PERSON_STATE(25),
	
	/** The INVALI d_ codeset. */
	INVALID_CODESET(26),
	
	/** The INVALI d_ group. */
	INVALID_GROUP(27),
	
	/** The INVALI d_ validatio n_ token. */
	INVALID_VALIDATION_TOKEN(28),
	
	/** The INVALI d_ accoun t_ name. */
	INVALID_ACCOUNT_NAME(29),
	
	/** The INVALI d_ contac t_ email. */
	INVALID_CONTACT_EMAIL(30),
	
	/** The INVALI d_ logi n_ name. */
	INVALID_LOGIN_NAME(31),
	
	/** The INVALI d_ password. */
	INVALID_PASSWORD(32),
	
	/** The INVALI d_ openquery. */
	INVALID_OPENQUERY(33),
	
	/** The INVALI d_ transform. */
	INVALID_TRANSFORM(34),
	
	/** The INVALI d_ relationshi p_ type. */
	INVALID_RELATIONSHIP_TYPE(35),
	
	/** The INVALI d_ credentia l_ type. */
	INVALID_CREDENTIAL_TYPE(36),
	
	/** The INVALI d_ recor d_ state. */
	INVALID_RECORD_STATE(37),
	
	/** The AP p_ aut h_ no t_ required. */
	APP_AUTH_NOT_REQUIRED(38),
	
	/** The REQUES t_ to o_ long. */
	REQUEST_TOO_LONG(39),
	
	/** The DUPLICAT e_ authorize d_ recor d_ found. */
	DUPLICATE_AUTHORIZED_RECORD_FOUND(40),
	
	/** The EMAI l_ no t_ verified. */
	EMAIL_NOT_VERIFIED(41),
	
	/** The DUPLICAT e_ grou p_ found. */
	DUPLICATE_GROUP_FOUND(42),
	
	/** The GROU p_ alread y_ ha s_ parent. */
	GROUP_ALREADY_HAS_PARENT(43),
	
	/** The GROU p_ membershi p_ cycl e_ detected. */
	GROUP_MEMBERSHIP_CYCLE_DETECTED(44),
	
	/** The MAI l_ addres s_ malformed. */
	MAIL_ADDRESS_MALFORMED(45),
	
	/** The PASSWOR d_ no t_ strong. */
	PASSWORD_NOT_STRONG(46),
	
	/** The CANNO t_ remov e_ las t_ custodian. */
	CANNOT_REMOVE_LAST_CUSTODIAN(47),
	
	/** The INVALI d_ emai l_ address. */
	INVALID_EMAIL_ADDRESS(48),
	
	/** The REQUES t_ time d_ out. */
	REQUEST_TIMED_OUT(49),
	
	/** The INVALI d_ sponso r_ email. */
	INVALID_SPONSOR_EMAIL(50),
	
	/** The INVALI d_ promotio n_ token. */
	INVALID_PROMOTION_TOKEN(51),
	
	/** The INVALI d_ recor d_ authorizatio n_ token. */
	INVALID_RECORD_AUTHORIZATION_TOKEN(52),
	
	/** The TO o_ man y_ group s_ i n_ query. */
	TOO_MANY_GROUPS_IN_QUERY(53),
	
	/** The GRAN t_ auth z_ exceed s_ default. */
	GRANT_AUTHZ_EXCEEDS_DEFAULT(54),
	
	/** The INVALI d_ vocabulary. */
	INVALID_VOCABULARY(55),
	
	/** The DUPLICAT e_ applicatio n_ found. */
	DUPLICATE_APPLICATION_FOUND(56),
	
	/** The RECOR d_ authorizatio n_ toke n_ expired. */
	RECORD_AUTHORIZATION_TOKEN_EXPIRED(57),
	
	/** The RECOR d_ authorizatio n_ doe s_ no t_ exist. */
	RECORD_AUTHORIZATION_DOES_NOT_EXIST(58),
	
	/** The TYP e_ typ e_ undeletable. */
	TYPE_TYPE_UNDELETABLE(59),
	
	/** The VERSIO n_ stam p_ missing. */
	VERSION_STAMP_MISSING(60),
	
	/** The VERSIO n_ stam p_ mismatch. */
	VERSION_STAMP_MISMATCH(61),
	
	/** The EXPIRE d_ openquery. */
	EXPIRED_OPENQUERY(62),
	
	/** The INVALI d_ publi c_ key. */
	INVALID_PUBLIC_KEY(63),
	
	/** The DOMAI n_ nam e_ no t_ set. */
	DOMAIN_NAME_NOT_SET(64),
	
	/** The AUTHENTICATE d_ sessio n_ toke n_ expired. */
	AUTHENTICATED_SESSION_TOKEN_EXPIRED(65),
	
	/** The INVALI d_ credentia l_ key. */
	INVALID_CREDENTIAL_KEY(66),
	
	/** The INVALI d_ perso n_ o r_ grou p_ id. */
	INVALID_PERSON_OR_GROUP_ID(67),
	
	/** The RECOR d_ quot a_ exceeded. */
	RECORD_QUOTA_EXCEEDED(68),
	
	/** The INVALI d_ datetime. */
	INVALID_DATETIME(69),	
	
    /** The Invalid certificate. */
    InvalidCertificate(70),
    
    /** The Response too long. */
    ResponseTooLong(71),
    
    /** The Invalid verification question. */
    InvalidVerificationQuestion(72),
   
    /** The Invalid verification answer. */
    InvalidVerificationAnswer(73),
    
    /** The Invalid identity code. */
    InvalidIdentityCode(74),
   
    /** The Retry limit exceeded. */
    RetryLimitExceeded(75),
    
    /** The Culture not supported. */
    CultureNotSupported(76),
   
    /** The Invalid file extension. */
    InvalidFileExtension(77),

    /** The Invalid vocabulary item. */
    InvalidVocabularyItem(78),

    /** The Duplicate connect request found. */
    DuplicateConnectRequestFound(79),

    /** The Invalid special account type. */
    InvalidSpecialAccountType(80),
    
    /** The Duplicate type found. */
    DuplicateTypeFound(81),

    /** The Credential not found. */
    CredentialNotFound(82),
    
    /** Cannot remove last credential. */
    CannotRemoveLastCredential(83),
	
	/** The UNKNOWN. */
	UNKNOWN(Integer.MAX_VALUE);
	
	private static EnumCodeLookup<StatusCode> map = 
		new EnumCodeLookup<StatusCode>(StatusCode.class);
	
	private int code;
	
	/**
	 * Instantiates a new status code.
	 * 
	 * @param code the code
	 */
	StatusCode(int code)
	{
		this.code = code;
	}
	
	/* (non-Javadoc)
	 * @see com.microsoft.hsg.EnumCode#getCode()
	 */
	public int getCode()
	{
		return code;
	}
	
	/**
	 * Parses the.
	 * 
	 * @param code the code
	 * 
	 * @return the status code
	 */
	public static StatusCode parse(int code)
	{
		StatusCode statusCode = map.get(code);
		if (statusCode == null)
		{
			statusCode = UNKNOWN;
		}
		return statusCode;
	}

}
